﻿using GeoCode.Core;
using MSGeoCoder.Services.Yahoo;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using MSGeoCoder;

namespace TestGeoCode
{
    
    
    /// <summary>
    ///This is a test class for YahooGeoCoderTest and is intended
    ///to contain all YahooGeoCoderTest Unit Tests
    ///</summary>
    [TestClass()]
    public class YahooGeoCoderTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///Postal code search will retuen a result which is accuracy is zip level or postal code level
        ///</summary>
        [TestMethod()]
        public void GeoCodeTest_PostalCode()
        {
            string appId = "AX70ugLV34GWIG_LOfNxSybXAAdfHcmnkbu0Fd1kBWMe5Ie6hyBzkDp8mwZ__i4ztQ--"; // TODO: Initialize to an appropriate value
            YahooGeoCoder target = new YahooGeoCoder(appId); // TODO: Initialize to an appropriate value
            string address = "KT6 4SW, UK"; // TODO: Initialize to an appropriate value
            
            Address[] expected = new Address[1]; // TODO: Initialize to an appropriate value
            expected[0] = new Address { Country = "GB", State = "United Kingdom", City = "London, Surbiton, KT6 4SW" };

            Address[] actual = actual = target.GeoCode(address);

            Assert.IsNotNull(actual);
            Assert.AreEqual(expected[0].Country, actual[0].Country);
            Assert.AreEqual(expected[0].State, actual[0].State);
            Assert.AreEqual(expected[0].City, actual[0].City);
        }

        /// <summary>
        ///A test for GeoCode
        ///</summary>
        [TestMethod()]
        public void GeoCodeTest1()
        {
            string appId = "AX70ugLV34GWIG_LOfNxSybXAAdfHcmnkbu0Fd1kBWMe5Ie6hyBzkDp8mwZ__i4ztQ--"; // TODO: Initialize to an appropriate value
            YahooGeoCoder target = new YahooGeoCoder(appId); // TODO: Initialize to an appropriate value
            string street = string.Empty; // TODO: Initialize to an appropriate value
            string city = string.Empty; // TODO: Initialize to an appropriate value
            string state = string.Empty; // TODO: Initialize to an appropriate value
            string postalCode = "KT6 4SW"; // TODO: Initialize to an appropriate value
            string country = "UK"; // TODO: Initialize to an appropriate value

            Address[] expected = new Address[1]; // TODO: Initialize to an appropriate value
            expected[0] = new Address { Country = "GB", State = "United Kingdom", City = "London, Surbiton, KT6 4SW" };

            Address[] actual;
            actual = target.GeoCode(street, city, state, postalCode, country);

            Assert.IsNotNull(actual);
            Assert.AreEqual(expected[0].Country, actual[0].Country);
            Assert.AreEqual(expected[0].State, actual[0].State);
            Assert.AreEqual(expected[0].City, actual[0].City);
      
        }
    }
}
